package com.dong.cruddemo.Cruddemo.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Generated;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * @author Fuyuko
 * @date 2019/12/12 15:00
 */
@Table(name="ACCOUNT")
@Entity
@Data
public class Account implements Serializable {
    @Id
    @GeneratedValue
    @Column(name="ACCOUNTNUMBER",updatable = false)
    private Integer accountNumber;

    @Column(name="ACCOUNTNAME")
    private String accountName;

    @Column(name="BALANCE")
    private BigDecimal balance;

    @Column(name="OPENINGDATE")
    private LocalDate openingDate;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "CUSTOMERID", nullable = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JsonIgnore
    private Customer customer;
}
